package booking;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by James.Owen on 08/02/14.
 */
public class AjaxCostResponseObject {
    private CostCalculator costCalculator;

    public AjaxCostResponseObject(CostCalculator costCalculator){
       this.costCalculator = costCalculator;
    }

    public Map<String, Object> getCostReturnObject() {

        BookingViewAdapter bookingViewAdapter = new BookingViewAdapter();
        String numberOfChildrenText = bookingViewAdapter.getNumberOfChildrenText(costCalculator.getNumberOfChildren());
        String costOfChildrenText = bookingViewAdapter.getCostOfChildrenText(costCalculator.getCostOfChildren());
        String totalCostText = bookingViewAdapter.getTotalCostText(costCalculator.getTotalCost());
        String packageCostText = bookingViewAdapter.getPartyPackageCostText(costCalculator.getPartyPackage().getCost());
        String partyBagsCostText = bookingViewAdapter.getPartyBagsCostText(costCalculator.getCostOfPartyBags());
        String costOfPlattersText = bookingViewAdapter.getCostOfPlatters((costCalculator.getDipPlatters() + costCalculator.getSandwichPlatters()) * 5.00);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("jazzyRequired", String.valueOf(costCalculator.getJazzyRequired()));
        map.put("jazzySelected", (costCalculator.getJazzyRequired() == true)?"Yes Please":"No thanks");
        map.put("partyBags", String.valueOf(costCalculator.getPartyBags()));
        map.put("partyBagsSelected", (costCalculator.getPartyBags() == true)?"Yes Please":"No thanks");
        map.put("costOfChildren", costOfChildrenText);
        map.put("numberOfChildren", numberOfChildrenText);
        map.put("costOfSandwichPlatters", String.valueOf(costCalculator.getSandwichPlatters() * 5.00));
        map.put("numberOfSandwichPlatters", String.valueOf(costCalculator.getSandwichPlatters()));
        map.put("costOfDipsPlatters", String.valueOf(costCalculator.getDipPlatters() * 5.00));
        map.put("numberOfDipsPlatters", String.valueOf(costCalculator.getDipPlatters()));
        map.put("totalNumberOfPlatters", String.valueOf((costCalculator.getDipPlatters() + costCalculator.getSandwichPlatters())));
        map.put("totalCostOfPlatters",costOfPlattersText);
        map.put("packageChosen", costCalculator.getPartyPackage().getName());
        map.put("packageCost", packageCostText);
        map.put("totalCost", totalCostText);

        if (costCalculator.getPartyBags() == true){
            map.put("partyBags", partyBagsCostText);
        }
        else{ map.put("partyBags","0.00");}

        if (costCalculator.getJazzyRequired() == true){
            map.put("jazzyRequired", "10.00");
        }
        else{map.put("jazzyRequired","0.00"); }

        return map;
    }
}
